#include <iostream>
using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  for (cin >> T; T; T--) {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    for (int i = 0; i < n + m; i++) {
      int tmp;
      cin >> tmp;
    }
    cout << n + m << "\n";
  }
  return 0;
}